# 数据工具包
import numpy as np
import pandas as pd
from tqdm import tqdm
import warnings

warnings.filterwarnings('ignore')
import os
import gc
import time
import datetime
import multiprocessing as mp
import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib

plt.rcParams["font.sans-serif"] = ["SimHei"]  # 设置字体
plt.rcParams["axes.unicode_minus"] = False  # 该语句解决图像中的乱码问题

pd.set_option('max_colwidth', 200)
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)

# 数据获取和预处理
register = pd.read_csv('../data/user_register_log.txt', sep='\t',
                       names=['user_id', 'register_day', 'register_type', 'device_type'])
launch = pd.read_csv('../data/app_launch_log.txt', sep='\t', names=['user_id', 'launch_day'])
create = pd.read_csv('../data/video_create_log.txt', sep='\t', names=['user_id', 'create_day'])
activity = pd.read_csv('../data/user_activity_log.txt', sep='\t',
                       names=['user_id', 'act_day', 'page', 'video_id', 'author_id', 'act_type'])

# print(register.head())
# print(launch.head())
# print(create.head())
# print(activity.head())
# print(register.info())
# sns.countplot(x='register_day', data=register)
# plt.show()

# 使用密度图对数据进行可视化
# plt.figure(figsize=(12, 5))
# plt.title('Distribution of register day')
# ax = sns.distplot(register['register_day'], bins=30)
# plt.show()

# 注册类型可视化分析
# sns.countplot(x='register_type', data=register)
# plt.show()

# sns.countplot(x='register_type', data=register[register['register_day'] == 24])
# sns.countplot(x='register_type', data=register[register['register_day'] == 23])
# plt.show()

# print(register['device_type'].value_counts())
# print(launch.info())

# sns.countplot(x='launch_day', data=launch)
# plt.show()

# print(launch['user_id'].value_counts())

# print(create.info())

# sns.countplot(x='create_day', data=create)
# plt.show()

# print(activity.info())

# sns.countplot(x='act_day', data=activity)
# plt.show()
